SRC = 'src/main/java/org/eclipse/jgit/'

gwt_module(
  name = 'client',
  srcs = [
    SRC + 'diff/Edit_JsonSerializer.java',
    SRC + 'diff/ReplaceEdit.java',
  ],
  gwt_xml = SRC + 'JGit.gwt.xml',
  deps = [
    '//lib:gwtjsonrpc',
    ':Edit',
  ],
  provided_deps = ['//lib/gwt:user'],
  visibility = ['PUBLIC'],
)

gwt_module(
  name = 'Edit',
  srcs = [':jgit_edit_src'],
  deps = [':edit_src'],
  visibility = ['PUBLIC'],
)

prebuilt_jar(
  name = 'edit_src',
  binary_jar = ':jgit_edit_src',
)

genrule(
  name = 'jgit_edit_src',
  cmd = 'unzip -qd $TMP $(location //lib/jgit/org.eclipse.jgit:jgit_src) ' +
    'org/eclipse/jgit/diff/Edit.java;' +
    'cd $TMP;' +
    'zip -Dq $OUT org/eclipse/jgit/diff/Edit.java',
  out = 'edit.src.zip',
)

java_library(
  name = 'server',
  srcs = [
    SRC + 'diff/EditDeserializer.java',
    SRC + 'diff/ReplaceEdit.java',
    SRC + 'internal/storage/file/WindowCacheStatAccessor.java',
    SRC + 'lib/ObjectIdSerialization.java',
  ],
  deps = [
    '//lib:gson',
    '//lib/jgit/org.eclipse.jgit:jgit',
  ],
  visibility = ['PUBLIC'],
)

java_test(
  name = 'jgit_patch_tests',
  srcs = glob(['src/test/java/**/*.java']),
  deps = [
    ':server',
    '//lib/jgit/org.eclipse.jgit:jgit',
    '//lib:junit',
  ],
  source_under_test = [':server'],
  visibility = ['//tools/eclipse:classpath'],
)
